home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / ZSI / auth.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  66 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from ZSI import *
  5. from ZSI import _copyright
  6. import base64
  7. import os
  8. _b64_decode = base64.decodestring
  9. _auth_tc = TC.Struct(None, [
  10.     TC.String('Name'),
  11.     TC.String('Password')], extras = 1)
  12.  
  13. class AUTH:
  14.     none = 0
  15.     httpbasic = 1
  16.     zsibasic = 2
  17.     httpdigest = 4
  18.  
  19.  
  20. class ClientBinding:
  21.     
  22.     def __init__(self, ps):
  23.         self.ps = ps
  24.         self.auth = None
  25.         self.environ = os.environ.copy()
  26.         self.environ['CONTENT_LENGTH'] = str(0)
  27.  
  28.     
  29.     def GetAuth(self):
  30.         if self.auth:
  31.             return self.auth
  32.         
  33.         for elt in self.ps.GetMyHeaderElements():
  34.             if elt.localName == 'BasicAuth' and elt.namespaceURI == ZSI_SCHEMA_URI:
  35.                 d = _auth_tc.parse(elt, self.ps)
  36.                 self.auth = (AUTH.zsibasic, d['Name'], d['Password'])
  37.                 return self.auth
  38.                 continue
  39.         
  40.         ba = self.environ.get('HTTP_AUTHENTICATION')
  41.         if ba:
  42.             ba = ba.split(' ')
  43.             if len(ba) == 2 and ba[0].lower() == 'basic':
  44.                 ba = _b64_decode(ba[1])
  45.                 self.auth = (AUTH.httpbasic,) + tuple(ba.split(':'))
  46.                 return self.auth
  47.             
  48.         
  49.         self.auth = (AUTH.none,)
  50.         return self.auth
  51.  
  52.     
  53.     def GetNS(self):
  54.         if not self.ps.body_root.namespaceURI:
  55.             pass
  56.         return ''
  57.  
  58.     
  59.     def GetRequest(self):
  60.         return self.ps
  61.  
  62.  
  63. if __name__ == '__main__':
  64.     print _copyright
  65.  
  66.